<?php


namespace app\admin\service;

use think\cache\driver\Redis;

/**
 * 上传-服务类
 * @author ZhangXuanNeng
 * @since 2020/11/19
 * Class UserService
 * @package app\admin\service
 */
class UploadService extends BaseService
{

    /**
     * 设置数据列表
     * @since 2020/11/19
     * @author ZhangXuanNeng
     */
    public function setDataRedis($data)
    {
        $key = 'uploadFilesTag';
        $redis      = new Redis(getRedisConfig());
        $_data = [];
        $_data['code'] = 2;
        $_data['real_file_path'] = $data['real_file_path'];
        $_data['file_name'] = $data['file_name'];
        $_data['dir'] = $data['dir'];
        $_data['decompression_size'] = $data['decompression_size'] ?? '';
        $fMad5key = md5($_data['file_name']);
        $redis->hSet($key, $fMad5key, $fMad5key);
        return $redis->set($fMad5key, json_encode($_data), 86400);
    }
    /**
     * 设置数据列表
     * @since 2020/11/19
     * @author ZhangXuanNeng
     */
    public function getDataRedis($data)
    {
        $redis      = new Redis(getRedisConfig());
        $fMad5key = md5($data['file_name']);
        return $redis->get($fMad5key);
    }

    public function delDataRedis($data): bool
    {
        $redis      = new Redis(getRedisConfig());
        $fMad5key = md5($data['file_name']);
        return $redis->rm($fMad5key);
    }



}